package top.riske.animalhazardassessment.common.http.request;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.riske.animalhazardassessment.common.entity.Animal;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
public class AnimalInputRequest {


    @TableId(type = IdType.AUTO)
    private Long id;

    @Schema(description = "姓名")
    private String name;

    @Schema(description = "物种")
    private String species;

    @Schema(description = "性别，0-未知，1-男，2-女")
    private Integer gender;

    @Schema(description = "生日")
    private LocalDate birthday;

    @Schema(description = "头像")
    private String avatar;

    @Schema(description = "动物主人ID")
    @TableField(value = "owner_id")
    private Long ownerId;

    @Schema(description = "省")
    private String province;

    @Schema(description = "市")
    private String city;

    @Schema(description = "区/县")
    private String district;

    @Schema(description = "详细地址")
    private String location;

    @Schema(description = "动物描述")
    private String description;

    @TableField(value = "risk_point")
    private Long riskPoint;

    @TableField(value = "status")
    private Integer status;

    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    public Animal toEntity() {
        Animal animal = new Animal();
        animal.setId(id);
        animal.setName(name);
        animal.setSpecies(species);
        animal.setGender(gender);
        animal.setBirthday(birthday);
        animal.setAvatar(avatar);
        animal.setOwnerId(ownerId);
        animal.setProvince(province);
        animal.setCity(city);
        animal.setDistrict(district);
        animal.setLocation(location);
        animal.setDescription(description);
        animal.setRiskPoint(riskPoint);
        animal.setStatus(status);
        animal.setCreateTime(createTime);
        return animal;
    }

    public AnimalInputRequest() {
    }
}
